﻿using CarRental.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CarRental {
    public partial class Site : System.Web.UI.MasterPage {
        protected void Page_Load(object sender, EventArgs e) {

            if (Shared.LoginInfo.Authorized == false) {
                hlLogin.Visible = true;
                hlRegister.Visible = true;
                hlSearchUser.Visible = false;
                hlEditUser.Visible = false;
                hlSearchCar.Visible = true;
                hlReviewOrder.Visible = false;
                hlMakeOrder.Visible = false;
                hlAddCar.Visible = false;
                hlReport.Visible = false;
                hlLogout.Visible = false;
            } else {
                lblUserName.Text = "LOGIN : " + Shared.LoginInfo.LoginName;
                if (Shared.LoginInfo.UserType == "ADMIN") {
                    hlLogin.Visible = false;
                    hlRegister.Visible = true;
                    hlSearchUser.Visible = true;
                    hlEditUser.Visible = true;
                    hlSearchCar.Visible = true;
                    hlReviewOrder.Visible = true;
                    hlMakeOrder.Visible = true;
                    hlAddCar.Visible = true;
                    hlReport.Visible = true;
                    hlContactUs.Visible = true;
                    hlLogout.Visible = true;
                } else if (Shared.LoginInfo.UserType == "STAFF") {
                    hlLogin.Visible = false;
                    hlRegister.Visible = true;
                    hlSearchUser.Visible = false;
                    hlEditUser.Visible = true;
                    hlSearchCar.Visible = true;
                    hlReviewOrder.Visible = true;
                    hlMakeOrder.Visible = true;
                    hlAddCar.Visible = false;
                    hlReport.Visible = true;
                    hlLogout.Visible = true;
                } else if (Shared.LoginInfo.UserType == "CUSTOMER") {
                    hlLogin.Visible = false;
                    hlRegister.Visible = false;
                    hlSearchUser.Visible = false;
                    hlEditUser.Visible = true;
                    hlSearchCar.Visible = true;
                    hlReviewOrder.Visible = true;
                    hlMakeOrder.Visible = true;
                    hlAddCar.Visible = false;
                    hlReport.Visible = false;
                    hlLogout.Visible = true;
                }

            }
            hlHome.NavigateUrl = ResolveUrl("~/View/Home/Home.aspx");
            hlLogin.NavigateUrl = ResolveUrl("~/View/Account/Login.aspx");
            hlRegister.NavigateUrl = ResolveUrl("~/View/Account/Register.aspx");
            hlSearchUser.NavigateUrl = ResolveUrl("~/View/Account/UserLst.aspx");
            hlEditUser.NavigateUrl = ResolveUrl("~/View/Account/EditUser.aspx");
            hlSearchCar.NavigateUrl = ResolveUrl("~/View/Car/SearchCar.aspx");
            hlReviewOrder.NavigateUrl = ResolveUrl("~/View/Order/ReviewOrder.aspx");
            hlMakeOrder.NavigateUrl = ResolveUrl("~/View/Order/MakeOrder.aspx");
            hlAddCar.NavigateUrl = ResolveUrl("~/View/Car/AddCar.aspx");
            //hlReport.NavigateUrl = ResolveUrl("~/View/Report/Report.aspx");
            hlContactUs.NavigateUrl = ResolveUrl("~/View/Home/ContactUs.aspx");
            hlLogout.NavigateUrl = ResolveUrl("~/View/Account/Logout.aspx");
        }
    }
}